package com.goldsprite.infinityworld.screens.examples.ui;

import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.utils.viewport.*;

import com.badlogic.gdx.scenes.scene2d.Stage;
import com.goldsprite.gdxcore.logs.LogViewerService;
import com.goldsprite.gdxcore.screens.GScreen;
import com.goldsprite.gdxcore.utils.ColorTextureUtils;
import com.goldsprite.infinityworld.assets.GlobalAssets;

public class WidgetGroupTransformExampleScreen extends GScreen {
	public Stage editorStage;
	public Stage gameStage;
	public OrthographicCamera screenCam, gameCam;
	public Viewport screenViewport, gameViewport;
	public Skin skin;

	private LogViewerService logViewer;

	@Override
	public Viewport getViewport() {
		return screenViewport;
	}


	@Override
	public void create() {
		skin = GlobalAssets.getInstance().editorSkin;

		logViewer = new LogViewerService(skin, 200, 200, "Window");

		float editorWidth = 960/1f, editorHeight = 540/1f;
		screenCam = new OrthographicCamera();
		screenViewport = new FitViewport(editorWidth, editorHeight, screenCam);
		screenViewport.apply(true);
		editorStage = new Stage(screenViewport);
		getImp().addProcessor(editorStage);
		{
			WidgetGroup widgetLayout = new WidgetGroup();
			widgetLayout.setFillParent(true);
			
			Table table = new Table(skin);
			//table.setFillParent(true);
			table.setBounds(100, 300, 400, 400);
			table.setBackground(ColorTextureUtils.createColorDrawable(Color.ORANGE));
			table.add("editorStage");
			widgetLayout.addActor(table);

			WidgetGroup table2 = new WidgetGroup();
			table2.setPosition(100, 0);
			table2.setScale(2f, 2f);
			widgetLayout.addActor(table2);
			
			Touchpad touchpad = new Touchpad(0, skin);
			touchpad.setBounds(100, 0, 150, 150);
			table2.addActor(touchpad);
			//stackLayout.addActor(table2);

			editorStage.addActor(widgetLayout);

			editorStage.addActor(logViewer.getRootLayout());
		}
	}

	@Override
	public void render(float delta) {
		super.render(delta);

		editorStage.act(delta);
		editorStage.draw();
	}

}

